// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
import 'core-js/stable'
import 'regenerator-runtime/runtime'
import '@/config/remConfig.js'

import Vue from 'vue'
// 全局引入按需引入UI库 element
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import App from './App.vue'
import router from './router'
import store from './store'

// 引入主题配置
import '@/assets/css/element-variables.scss';

// 引入动画样式
import 'animate.css';



Vue.use(ElementUI)

Vue.use(require('vue-moment'));

// 修改 el-dialog 默认点击遮照为不关闭
ElementUI.Dialog.props.closeOnClickModal.default = false

// 设置 js中可以访问 $cdn
import { $cdn } from '@/config'
Vue.prototype.$cdn = $cdn

// 全局引入按需引入UI库 vant
// import '@/plugins/vant'
// 引入全局样式
import '@/assets/css/common.scss'
// 移动端适配
// import 'lib-flexible/flexible.js'

// filters
import './filters'
Vue.config.productionTip = false

//导航守卫
router.beforeEach((to, from, next) => {
  window.document.title = to.meta.title === undefined?'FFAM':to.meta.title
  if (to.meta.requireAuth) {
    let token = Cookies.get('access_token');
    let anonymous = Cookies.get('user_name');
    if (token) {

      next({
        path: '/login',
        query: {
          redirect: to.fullPath
        }
      })

    }
  }
  next();
})

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
